-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime: Refactor conn cache to contain and detect hanging opens/closes #3666
Runtime: Refactor conn cache to contain and detect hanging opens/closes #3666
Conversation
closed bool | ||
mu sync.Mutex | ||
entries map[string]*entry | ||
lru *simplelru.LRU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also expose metrics around lru
and entries
size and optionally connection open
and close
times.
runtime/pkg/conncache/conncache.go
Outdated
// Options configures a new connection cache. | ||
type Options struct { | ||
// MaxConnectionsIdle is the maximum number of non-acquired connections that will be kept open. | ||
MaxConnectionsIdle int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Usually the name is MaxIdleConnections
(https://pkg.go.dev/database/sql#DB.SetMaxIdleConns)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
…es (#3666) * Runtime: Refactor conn cache to contain and detect hanging opens/closes * Extract connection cache to pkg + use a singleflight * Add tests * Make tests pass * increase test sleeps for clsoe * Fix various race conditions * Integrate singleflight with conncache's mutex * Increase timeouts * Better comments * Prevent deadlock when closing while opening * Address review comments * Remove redundant var
…es (#3666) * Runtime: Refactor conn cache to contain and detect hanging opens/closes * Extract connection cache to pkg + use a singleflight * Add tests * Make tests pass * increase test sleeps for clsoe * Fix various race conditions * Integrate singleflight with conncache's mutex * Increase timeouts * Better comments * Prevent deadlock when closing while opening * Address review comments * Remove redundant var (cherry picked from commit fa2e166)
These refactors enable:
Contributes to https://github.com/rilldata/rill-private-issues/issues/17